package com.example.webchar.webchar.mapper.slave;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.webchar.webchar.pojo.ChapterName;
import com.example.webchar.webchar.pojo.Novel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: wechat-web-is-my
 * @description
 * @author: 郭逍
 * @create: 2021/8/21 10:57
 **/
@Mapper
@Service
public interface ChapterNameSlave extends BaseMapper<ChapterName> {
    /**
     * 根据输入的小数目录集合查询所有符何条件的章节信息
     *
     * @param novels
     * @return
     */
    @Select("<script> select * from chapter_name where novel_id in <foreach  item='item' index='index' collection='novels' open='(' separator=',' close=')'> #{item.id}</foreach> </script>")
    List<ChapterName> quereChapter(@Param("novels") List<Novel> novels);

    /**
     * 根据章节信息id 查询章节信息
     *
     * @param chapterNameId
     * @return
     */
    @Select("select * from chapter_name where id=#{chapterNameId}")
    List<ChapterName> querChapterNameById(@Param("chapterNameId") Integer chapterNameId);

    /**
     * 根据目录id查询 当前小说的所有章节信息
     *
     * @param novelId
     * @return
     */
    @Select("select * from chapter_name where novel_id=#{novelId}")
    List<ChapterName> quereyChapterNameById(@Param("novelId") Integer novelId);

}
